<template>
	<view>

		<u-tabbar v-model="current" :list="list" :mid-button="true" :before-switch="beforeSwitch"></u-tabbar>

		<!-- 模态框 -->
		<u-modal v-model="show">
			<view class="modal-box">
				<u-button type="warning" size="medium" @click="toSell">出售发布</u-button>

				<u-button type="error" size="medium" @click="toBuy">求租发布</u-button>
			</view>
		</u-modal>
	</view>
</template>

<script>
	export default {
		props: ['current'],
		data() {
			return {
				list: [{
						iconPath: "/static/image/menu/index.png",
						selectedIconPath: "/static/image/menu/index_s.png",
						text: '首页',
						count: 2,
						isDot: true,
						customIcon: false,
					},
					{
						iconPath: "/static/image/menu/fabu.png",
						selectedIconPath: "/static/image/menu/fabu_s.png",
						text: '求租',
						customIcon: false,
					},
					{
						iconPath: "plus",
						selectedIconPath: "plus",
						text: '发布',
						midButton: true,
						customIcon: false,
					},
					{
						iconPath: "/static/image/menu/shop.png",
						selectedIconPath: "/static/image/menu/shop_s.png",
						text: '出租',
						customIcon: false,
					},
					{
						iconPath: "/static/image/menu/my.png",
						selectedIconPath: "/static/image/menu/my_s.png",
						text: '我的',
						count: 23,
						isDot: false,
						customIcon: false,
					},
				],
				show: false
			}
		},
		methods: {
			beforeSwitch(index) {
				if (index == 0) {
					uni.switchTab({
						url: '/pages/index/index'
					})
				} else if (index == 1) {
					uni.switchTab({
						url: '/pages/qiuzu/qiuzu'
					})
				} else if (index == 3) {
					uni.switchTab({
						url: '/pages/chuzu/chuzu'
					})
				} else if (index == 4) {
					uni.switchTab({
						url: '/pages/my/my'
					})
				} else {
					this.show = true
				}

			},

			// 跳转到出售发布
			toSell() {
				uni.navigateTo({
					url: "/pages/issue/issueSell"
				})
			},
			// 跳转到出租发布
			toBuy() {
				uni.navigateTo({
					url: "/pages/issue/issueBuy"
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	//模态框
	.modal-box {
		padding: 30rpx;
		display: flex;
		justify-content: space-between;
	}
</style>
